/**
 * https://leetcode-cn.com/problems/container-with-most-water/
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function(height) {
    let l = 0;
    let r = height.length - 1;
    let maxArea = 0;
    while (l < r) {
        let bail = Math.min(height[l], height[r]);
        // update max area;
        const area = (r - l) * bail;
        if (maxArea < area) {
            maxArea = area;
        }
        if (bail === height[l]) {
            l++;
        }
        if (bail === height[r]) {
            r--;
        }
    }
    return maxArea
};